package com.jfinal.bbsapp.course;
import java.util.List;
import org.apache.log4j.Logger;
import com.jfinal.bbsapp.common.kit.MyAnnotation;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

@MyAnnotation(memo="课程业务类")
public class CourseService {
	private final Logger logger = Logger.getLogger(CourseService.class);

	@MyAnnotation(memo="获取课程章节")
	public Ret chapterlist(String courseid) {
		List<Record> list = null;
		try {
			StringBuilder sql = new StringBuilder();
			sql.append("select cast(courseid as char) courseid,cast(chapterid as char) chapterid,chaptername,"
				+ "img,CEILING(classhour/60) classhour,ifnull(annex,'') annex,videourl,isfree,price,sortno,ifnull(memo,'') memo");
			sql.append(" from c_chapter where courseid=? and flag='1'");
			sql.append(" order by sortno asc");
			list = Db.find(sql.toString(),courseid);
			return Ret.ok("data", list).set("code", 20000);
		} catch (Exception e) {
			logger.error("------Exception------", e);
			return Ret.fail("系统异常").set("code", 50000);
		}
	}
}